'use strict';
module.exports = app => {
    const { STRING, INTEGER } = app.Sequelize;
    const comment =  app.model.define(
        'comment',
        {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            user_id: INTEGER,
            consult_id: INTEGER,
            content: STRING,
        },
        {
            tableName: 'comment',
            timestamps: true, // 启用时间戳(createdAt, updatedAt)
            updatedAt: 'updated_time', // 不想要 updatedAt
            createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
        }
    );
    comment.associate = function() {
        app.model.Comment.belongsTo(app.model.User, {foreignKey: 'user_id', targetKey: 'id'});
    }
    return comment
};
